/**
 * @file cmd_base.c
 * @brief 
 * @author  ()
 * @version 1.0
 * @date 2024-09-13
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-13 <td>1.0     <td>     <td>内容
 * </table>
 */
#include <stdio.h>
#include "lettershell/shell.h"
#include "../shell_log.h"
#include "misc/hwmisc.h"
#include "misc/version.h"

#include "modem/qlmodem/include/qlmodemconfdefs.h"


int32_t cmd_base(void)
{
    const char *hd_ver = get_hw_ver();

    printf(DEV_BASIC_INFO CPU_BASIC_INFO
            "The firmware version:%s(%s %s), the modem library version:%s, and the hardware version:%s.\r\n"
            "And the cpu is running at a frequency of %lu Hz now.\r\n",
            SOFTWARE_VERSION, __DATE__, __TIME__, qlmodem_version, hd_ver, configCPU_CLOCK_HZ);

    return 0;
}

SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN,
                 base, cmd_base, show base info);





// extern void cfg_parse(uint8_t id, uint8_t* payload, uint16_t len);
// int32_t co_cfg_cmd_set_ca(void)
// {
//     extern const char *tls_ca_cert;

//     uint32_t file_len = strlen(tls_ca_cert);
//     int i = 0x11;
//     int file_offset = 0;
//     while(file_len > 0) {
//         char payload[70 + 1] = {0};
//         char *line_end = strstr(tls_ca_cert + file_offset, "\r\n");
        
//         if(line_end != NULL) {
//            line_end += 2;  
//         } else {
//             break;
//         }
        
    
//         int payload_len = line_end - (tls_ca_cert + file_offset);
//         memcpy(payload, tls_ca_cert + file_offset, payload_len);
//         cfg_parse(i++, (void *)payload, payload_len);

//         file_len -= payload_len;
//         file_offset += payload_len;
//     }

//     cfg_parse(0x11, (uint8_t *)tls_ca_cert, 0);

 
//     return 0;
// }
 
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN,
//                   co_cmd_ca, co_cfg_cmd_set_ca, function test co-cmd ca file);


// int32_t co_cfg_cmd_set_server(void)
// {

//    char cfg_cmd_0x10_payload[66] = {0};
//    strcpy(cfg_cmd_0x10_payload, "192.168.0.1");
//    unsigned short port = 3120;
//    memcpy(&cfg_cmd_0x10_payload[64], &port, 2);

//    cfg_parse(0x10, (void *)cfg_cmd_0x10_payload, 66);

//    cfg_parse(0x10, (void *)cfg_cmd_0x10_payload, 0);
//    return 0;
// }

// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN,
//                 co_cmd_server, co_cfg_cmd_set_server, function test co-cmd server ip);

